layui.config({
    base: $config.resUrl+'other/'//定义基目录
}).extend({
    ajaxExtention:'js/ajaxExtention',//加载自定义扩展，每个业务js都需要加载这个ajax扩展
    $tool:'js/tool',
    $api:'js/api'
}).use(['form','layer','laydate','ajaxExtention','$tool','$api'], function() {
	var $ = layui.jquery, 
	laydate = layui.laydate,
	dtree = layui.dtree,
	form = layui.form,
	layer = layui.layer,
	$tool = layui.$tool,
    $api = layui.$api;
	
	//日期
	laydate.render({
    elem: '#operateTime'
	});
	
	//监听提交按钮
	form.on('submit(roleEditSubmit)', function(data){
		
	  if("no" == data.field.id){
		  $api.RoleSave(data.field,function(data){
			  layer.msg(data.msg,{time: 500},function(){
				  parent.tableIns.reload();
				  parent.layer.closeAll();
			  });
		  },function(error){
			  layer.msg(error.msg);
		  });
	  }else{
		  $api.RoleUpdate(data.field,function(data){
			  layer.msg(data.msg,{time: 500},function(){
				  parent.tableIns.reload();
				  parent.layer.closeAll();
			  });
		  },function(error){
			  layer.msg(error.msg);
		  });
	  }
  });
});
